<template>
	<paginationScrolling ref="paginationScrolling" :tabList="tabList" :swiperCur="swiperCur" @tabChange="tabChange" @scrolltoupper="scrolltoupper" @scrolltolower="scrolltolower">
		<template v-for="(item, index) in tabList" :slot="'scrollList' + index">
			<slot :name="'scrollList' + index" :list="list"></slot>
		</template>
	</paginationScrolling>
</template>

<script>
	import { scrollViewScroll } from './mixins.js';
	import paginationScrolling from './paginationScrolling.vue';
	export default {
		name: 'house',
		mixins: [scrollViewScroll],
		props: {
			tabList: {
				type: Array,
				default: () => [],
			},
			api: {
				type: String,
				default: '',
			},
			apiData: {
				type: String,
				default: '',
			},
			swiperCur: {
				type: Number,
				default: 0,
			},
		},
		watch: {
			swiperCur() {
				this.reset()
				this.init();
			},
		},
		data() {
			return {};
		},
		created() {
			this.init();
		},
		methods: {
			async init() {
				let obj = {};
				obj[this.apiData] = this.tabList[this.swiperCur][this.apiData];
				const { data } = await this.$api[this.api](obj);
				this.page.count = data.count;
				if(data.list){
					this.list = [...this.list, ...data.list];
				}else{
					this.list = [...this.list, ...data.lists];
				}
				
			},
		},
	};
</script>

<style lang="scss"></style>
